﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Ls.Utils
{
    public static class DirectoryInfoExt
    {
        public static List<FileInfo>  GetFiles(this DirectoryInfo dic, SearchOption searchOption, params string[] searchPatterns) {
            List<FileInfo> result = new List<FileInfo>();
            foreach (var searchPattern in searchPatterns)
            {
                var file  = dic.GetFiles(searchPattern, searchOption);
                if (file != null && file.Length >0)
                {
                    result.AddRange(file);
                }
            } 
            return result;
        }
    }
}
